package demo.mao;

public class BubbleSort {
    public static void main(String[] args) {
        int[] arr = {5, 4, 6, 9, 8, 7, 3, 1};
        for (int i = 0; i < arr.length - 1; i++) {
            for (int w = 0; w < arr.length - 1 - i; w++) {
                if (arr[w] > arr[w + 1]) {
                    int tamp = arr[w + 1];
                    arr[w + 1] = arr[w];
                    arr[w] = tamp;
                }
            }
        }
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + "  ");
        }

    }
}
